<template>
  <div class="contain">
    <div class="header">
      <el-button type="primary" @click="$router.push('/messageEdit')">发布消息</el-button>
      <!--<el-button style="display:none" type="primary" @click="addCard()">批量导入</el-button>-->
    </div>
    <div class="input_modal">
      <div class="input-item" v-if="identify == 1">
        <span>消息标题：</span>
        <el-input v-model="configList.param.titleLike" placeholder="请输入内容" class="proName"  @keyup.enter.native="search"></el-input>
      </div>
      <div class="input-item" v-else-if="identify == 0">
        <span>消息类型：</span>
        <el-select v-model="configList.param.messageType" placeholder="请选择">
          <el-option
            v-for="item in typeList"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </div>
      <div class="input-item">
        <el-button type="primary" @click="getList">查询</el-button>
      </div>
    </div>
    <div class="table-content">
      <table-list ref="tableList" :tableConfig='configList' @selectTable="selectTable">
        <el-table-column
          slot="select"  align="center" label="全选"
          type="selection"
          width="55">
        </el-table-column>
        <el-table-column min-width="120px"  align="center">
        </el-table-column>
        <!--<el-table-column slot="content"  align="center" label="公告内容">-->
            <!--<template slot-scope="scope">-->
                <!--<div v-html="scope.row.mobile">{{scope.row.content}}</div>-->
            <!--</template>-->
        <!--</el-table-column>-->
        <el-table-column class="btn"  min-width="240px" label="操作" slot="btn" align="center" >
          <template slot-scope="scope">
            <el-button  @click="$router.push('/messageDetail?id='+scope.row.id)" type="primary" size="small">查看</el-button>
            <el-button  @click="$router.push('/messageEdit?id='+scope.row.id)" type="primary" size="small">编辑</el-button>
            <el-button  class="search-btn" size="small" type="danger" @click="deleteItem(scope.row.id)">删除</el-button>
            <!-- <el-button v-if="scope.row.isRefundBtn == 'y'" class="search-btn" size="small" type="danger" @click="refundBtn(scope.row.id)">退款</el-button> -->
          </template>
        </el-table-column>
      </table-list>
    </div>

  </div>
</template>
<script>
  let CONSTANT = require("../../constant/constant.js");
  let common = require("../../common.js");
  export default{
    data(){
      return {
        categoryId:'',
        isSale:'',
        coverImage:[],
        searchName:'',
        pageCount:null,
        pageIndex:1,
        pageSize:10,
        informList:[],
        allThemeList:[],
        themeList:[],
        typeList: [{
          label: "全部",
          value: ""
        },{
          label: "房客消息",
          value: "renter_message"
        },{
          label: "房东消息",
          value: "landlord_message"
        },{
          label: "房东公告",
          value: "landlord_declare"
        },{
          label: "平台公告",
          value: "platform_declare"
        }],
        configList:{
          url:"",
          configList:[
            {
              slot: "select"
            },
            {
              label:'公告标题',
              prop:'title',
            },
            {
              label:'公告内容',
              prop:'content',
            },
            {
              slot:'btn'
            }
          ],
          param:{
            titleLike: "",
            messageType: ""
          },
          type:'',
          width:'',
          isPagination:true,

          identify: ""
        },
      }
    },
    components: {
      'table-list':() => import('../common/my-table')
    },
    created() {
      this.identify = sessionStorage.getItem("identify");
      if (this.identify == 1) {
        this.configList.url = CONSTANT.URL.MESSAGE.LIST
      } else {
        this.configList.url = CONSTANT.URL.L_MESSAGE.LIST
      }
    },
    mounted() {

    },
    methods: {
      getList(){
        this.$refs.tableList.getList()
      },
      selectTable() {

      },
      //删除
      deleteItem(id){
        this.$confirm('确定删除?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let  url = "";
          if (this.identify == 1) {
            url = CONSTANT.URL.MESSAGE.DELETE
          } else {
            url = CONSTANT.URL.L_MESSAGE.DELETE
          }
          let data = {id:id} ;
          common.requestAjax(url,{},data,(res)=>{
            if(res.status == 200){
              this.$message({
                type:'success',
                message:'删除成功!'
              });
              this.getList();
            }
            else{
              this.$message({
                type:'warning',
                message:res.msg
              })
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        });
      },
      //新增编辑
      addCard(id){
        this.$router.push({path:'/informationDetail',query:{'id':id}});
      },
    },
  }
</script>

<style lang="scss">
  .contain {
    .el-dialog__body{ padding-left: 0;padding-top: 30px;border-top:1px solid #dedede;}
    .dialog-con{
      background-color: #f5f5f5;
      display: flex;
      justify-content: space-between;
      ul{
        width:28%;list-style: none;padding:0;font-size:14px;float: left;margin-top:0;z-index:999;
        li{ list-style: none;height:60px;line-height:60px;text-align: center;display: block;}
        li.active{color:#21b5cc;background-color: #fff;font-size:16px;border-right:2px solid #21b5cc;}
        //   li:hover{font-size:16px; }
      }
      .tab-content{ width: 70%;display: inline-block;padding-left:10%;background-color: #fff;min-height:300px;
        .sort{
          .sort_name{ font-weight: 600;margin-bottom: 5px;}
          .group-list{ padding-left: 20px;
            .el-radio{display:block;margin-left: 0;margin-bottom: 3px;}
          }
        }
      }
      .el-button--default{background-color: #fff !important;}
    }
  }
</style>
